﻿
@{
    var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
    var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;

    //page title
    ViewBag.Title = T("Admin.RecurringPayments").Text;
}
<div class="section-header">
    <div class="title">
        <img src="@Url.Content("~/Administration/Content/images/ico-sales.png")" alt="" />
        @T("Admin.RecurringPayments")
    </div>
    <div class="options">
        
    </div>
</div>
<table class="adminContent">
    <tr>
        <td>
            <div id="recurringpayments-grid"></div>

            <script>
                $(document).ready(function() {
                    $("#recurringpayments-grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            transport: {
                                read: {
                                    url: "@Html.Raw(Url.Action("List", "RecurringPayment"))",
                                    type: "POST",
                                    dataType: "json"
                                }
                            },
                            schema: {
                                data: "Data",
                                total: "Total",
                                errors: "Errors"
                            },
                            error: function(e) {
                                display_kendoui_grid_error(e);
                                // Cancel the changes
                                this.cancelChanges();
                            },
                            pageSize: @(defaultGridPageSize),
                            serverPaging: true,
                            serverFiltering: true,
                            serverSorting: true
                        },
                        pageable: {
                            refresh: true,
                            pageSizes: [@(gridPageSizes)]
                        },
                        editable: {
                            confirmation: false,
                            mode: "inline"
                        },
                        scrollable: false,
                        columns: [
                            {
                                field: "Id",
                                title: "@T("Admin.RecurringPayments.Fields.ID")",
                                width: 50
                            }, {
                                field: "CustomerId",
                                title: "@T("Admin.RecurringPayments.Fields.Customer")",
                                width: 200,
                                template: '<a href="@Url.Content("~/Admin/Customer/Edit/")#=CustomerId#">#:CustomerEmail#</a>'
                            }, {
                                field: "CycleLength",
                                title: "@T("Admin.RecurringPayments.Fields.CycleLength")",
                                width: 50
                            }, {
                                field: "CyclePeriodStr",
                                title: "@T("Admin.RecurringPayments.Fields.CyclePeriod")",
                                width: 100
                            }, {
                                field: "IsActive",
                                title: "@T("Admin.RecurringPayments.Fields.IsActive")",
                                width: 100,
                                headerAttributes: { style: "text-align:center" },
                                attributes: { style: "text-align:center" },
                                template: '<img src="@Url.Content("~/Administration/Content/images/")active-#=IsActive#.gif" />'
                            }, {
                                field: "StartDate",
                                title: "@T("Admin.RecurringPayments.Fields.StartDate")",
                                width: 200,
                                type: "date",
                                format: "{0:G}"
                            }, {
                                field: "NextPaymentDate",
                                title: "@T("Admin.RecurringPayments.Fields.NextPaymentDate")",
                                width: 200,
                                type: "date",
                                format: "{0:G}"
                            }, {
                                field: "TotalCycles",
                                title: "@T("Admin.RecurringPayments.Fields.TotalCycles")",
                                width: 100
                            }, {
                                field: "CyclesRemaining",
                                title: "@T("Admin.RecurringPayments.Fields.CyclesRemaining")",
                                width: 100
                            }, {
                                field: "Id",
                                title: "@T("Admin.Common.Edit")",
                                width: 100,
                                template: '<a href="Edit/#=Id#">@T("Admin.Common.Edit")</a>'
                            }
                        ]
                    });
                });
            </script>
        </td>
    </tr>
</table>